﻿using Arch.EntityFrameworkCore.UnitOfWork.Collections;
using Common.Lib.Dto;
using Common.Lib.Parameter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common.Lib.Service
{
    public class ToDoService: BaseService<ToDoDto>, IToDoService
    {
        private readonly HttpRestClient client;

        public ToDoService(HttpRestClient client) : base(client, "ToDo")
        {
            this.client = client;
        }

        public async Task<ApiResponse<PagedList<ToDoDto>>?> GetAllFilterAsync(ToDoQueryParameter queryParameter)
        {
            BaseRequest request = new BaseRequest();
            request.Method = RestSharp.Method.Get;
            request.Route = $"api/ToDo/GetAllFilter?pageIndex={queryParameter.PageIndex}&pageSize={queryParameter.PageSize}&searchKey={queryParameter.SearchKey}&status={queryParameter.Status}";            
            return await client.ExecuteAsync<PagedList<ToDoDto>>(request);
        }

        public async Task<ApiResponse<SummaryDto>> Summary()
        {
            BaseRequest request = new BaseRequest();
            request.Method = RestSharp.Method.Get;
            request.Route = $"api/ToDo/Summary";
            return await client.ExecuteAsync<SummaryDto>(request);
        }
    }

    public interface IToDoService:IBaseService<ToDoDto>
    {
        Task<ApiResponse<PagedList<ToDoDto>>?> GetAllFilterAsync(ToDoQueryParameter queryParameter);

        Task<ApiResponse<SummaryDto>> Summary();

    }
}
